{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a35ad389",
   "metadata": {},
   "source": [
    "-----------\n",
    "* 本学习记录人：戴祥哲\n",
    "* 学习时间：2021-12-02\n",
    "* week09\n",
    "* [参考文档](https://python.org/doc)\n",
    "* [徐老师博客](https://cnblogs.com/xuzhichao)\n",
    "-----------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56a46be5",
   "metadata": {},
   "source": [
    "# 本周重点知识\n",
    "\n",
    "## 1. 初始字典\n",
    "## 2. 字典的一般创建方法\n",
    "## 3. 字典的操作\n",
    "## 4. 实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3e6b6687",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n",
      "{'jack': 4098, 'sape': 4139}\n"
     ]
    }
   ],
   "source": [
    "tel = {'jack': 4098, 'sape': 4139}\n",
    "print(type(tel))\n",
    "print(tel)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a6a4fc2f",
   "metadata": {},
   "source": [
    "> 'jack' 是 关键字 (key)  \n",
    "> 4098 是 值 (value)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35f3a31b",
   "metadata": {},
   "source": [
    "# 1. 初识[字典](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)\n",
    "* Another useful data type built into Python is the dictionary (see Mapping Types — dict) **<font style=\"color:red\">映射数据类型</font>**\n",
    "* 对比序列数据 VS 映射数据\n",
    ">> 1. 序列数据 index 是 从0开始，每次加一的 数值作为索引值 [88,87,90]\n",
    ">> 2. 映射数据 index 是 **关键字**（不可变数据，例如字符串，数字，元组）\n",
    ">> 3. 序列数据是 **有顺序的**\n",
    ">> 4. 映射数据是 **无序的**\n",
    ">> 5. 序列数据 index 是不写在数据值中的，不显示的\n",
    ">> 6. 映射数据 index 作为 关键字（key）写在数据结构中 ： {key:value} 这种形式通常被人们称为 **键值对（key: value pairs）**\n",
    "\n",
    "* 总结字典的性质：\n",
    "> 1. 字典的key 是唯一的 (唯一性)\n",
    "> 2. 字典是没有顺序的（无序性）\n",
    "> 3. 字典的key是不可变的(不变性)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2b3828a",
   "metadata": {},
   "source": [
    "# 2.字典的一般创建方法\n",
    "    \n",
    "> 1. 按照字典的数据结构直接创建\n",
    ">> * dict_name = {key1:value1 , key2:value2 , key3:value3 , ...}\n",
    "> 2. 使用dict()方法创建字典\n",
    ">> * dict_name = dict(key1=value1 , key2=value2 , key3=value3 , ...)\n",
    "> 3. 使用字典新增的方式创建字典\n",
    ">> * dict_name[key1] = value1 , dict_name[key2] = value2 , dict_name[key3] = value3 ,..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "f159a846",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}\n"
     ]
    }
   ],
   "source": [
    "# 1. 按照字典的形式创建字典\n",
    "stud_info = {\n",
    "    \"stud_2101\":\"傻逼\",\n",
    "    \"stud_2102\":\"呆逼\",\n",
    "    \"stud_2103\":\"牛逼\"\n",
    "}\n",
    "print(stud_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "170a4a8b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}\n"
     ]
    }
   ],
   "source": [
    "# 2. 使用dict()方法创建字典\n",
    "stud_info2 = dict(\n",
    "    stud_2101=\"傻逼\",\n",
    "    stud_2102=\"呆逼\",\n",
    "    stud_2103=\"牛逼\"\n",
    ")\n",
    "print(stud_info2)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "ad0be81f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}\n"
     ]
    }
   ],
   "source": [
    "# 3. 使用字典新增的方式创建字典\n",
    "stud_info3 = {}\n",
    "\n",
    "stud_info3[\"stud_2101\"]=\"傻逼\"\n",
    "stud_info3[\"stud_2102\"]=\"呆逼\"\n",
    "stud_info3[\"stud_2103\"]=\"牛逼\"\n",
    "\n",
    "print(stud_info3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b0ee7aef",
   "metadata": {},
   "source": [
    "# 3.字典的操作\n",
    "\n",
    "\n",
    "> 1. 字典的增删改<font style=\"color:red\">**查**</font>\n",
    ">> 1. 字典的查询\n",
    "> 2. 字典的一般方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "910c6992",
   "metadata": {},
   "source": [
    "> 1. 字典的查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "9bb5e949",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "49938796",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "呆逼\n"
     ]
    }
   ],
   "source": [
    "# 字典的查询方法1：\n",
    "if 'stud_2102' in stud_info:\n",
    "    print(stud_info['stud_2102'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "0f3c538d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'stud_2104' in stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "ee0f63fe",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'stud_2104'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-38-3ed44e5eb782>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mstud_info\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'stud_2104'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m: 'stud_2104'"
     ]
    }
   ],
   "source": [
    "stud_info['stud_2104']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "a43ecf19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "呆逼\n"
     ]
    }
   ],
   "source": [
    "# 字典的查询方法2：\n",
    "# 利用 dict.get() 查询,如果值存在的话，直接返回查询的内容；如值不存在，返回None\n",
    "print(stud_info.get('stud_2102'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "3cf6598f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(stud_info.get('stud_2104'))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4dcf6873",
   "metadata": {},
   "source": [
    "> 2. 字典的修改和增加:dict[key]=value\n",
    ">> 1. 查询是否存在，如果存在的话，修改\n",
    ">> 2. 查询是否存在，如果不存在的话，增加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "3ebcedc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "64ed1f70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1. 字典的增加\n",
    "\n",
    "'stud_2104' in stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "0703ff2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "stud_info['stud_2104']='丑逼'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "f9ed46a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2102': '帅逼', 'stud_2103': '牛逼', 'stud_2104': '丑逼'}"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "41e6de08",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2. 字典的修改\n",
    "\n",
    "'stud_2102' in stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "cc5f7c23",
   "metadata": {},
   "outputs": [],
   "source": [
    "stud_info['stud_2102']='帅逼'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "d38cfff8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2102': '帅逼', 'stud_2103': '牛逼', 'stud_2104': '丑逼'}"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d8ee403",
   "metadata": {},
   "source": [
    "> 3. 字典的删除\n",
    ">> 1. pop(),指定关键字进行删除\n",
    ">> 2. popitom()，随机删除一个字典的内容，返回删除的键值对信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "dc0847d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(...) method of builtins.dict instance\n",
      "    D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n",
      "    If key is not found, d is returned if given, otherwise KeyError is raised\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(stud_info.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "210fd8f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'stud_2102' in stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "ea021726",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'帅逼'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info.pop('stud_2102')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "c49aeed4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2103': '牛逼', 'stud_2104': '丑逼'}"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "3401d4c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function popitem:\n",
      "\n",
      "popitem() method of builtins.dict instance\n",
      "    Remove and return a (key, value) pair as a 2-tuple.\n",
      "    \n",
      "    Pairs are returned in LIFO (last-in, first-out) order.\n",
      "    Raises KeyError if the dict is empty.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(stud_info.popitem)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "0397b45c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('stud_2104', '丑逼')"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "3c94431f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2103': '牛逼'}"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef947c47",
   "metadata": {},
   "source": [
    "> 4. 字典的循环\n",
    ">> 1. 根据字典的 key：value 的结构，我们循环将循环**两个变量**\n",
    ">> 2. 方法 for k,v in Dict.items()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "01ab6361",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_2101': '傻逼', 'stud_2102': '呆逼', 'stud_2103': '牛逼'}"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "9f321b64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stud_2101 傻逼\n",
      "stud_2102 呆逼\n",
      "stud_2103 牛逼\n"
     ]
    }
   ],
   "source": [
    "for k,v in stud_info2.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48a6b2ff",
   "metadata": {},
   "source": [
    "# 4. 字典的一般方法（课后实践）\n",
    "\n",
    "> 1. 使用help()查看**每一种**字典的方法\n",
    "> 2. 如果没看懂，请搜索六篮球找寻答案\n",
    "> 3. 实践每一种方法\n",
    "> 4. 使用表格总结每一种方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "173a8897",
   "metadata": {},
   "source": [
    "# 5. 字典的查询实践\n",
    "\n",
    "[实践的数据链接](https://apic.liepin.com/api/com.liepin.searchfront4c.pc-search-condition-list?traceId=44657309842)\n",
    "\n",
    "> 1. 请大家找出来 关键字为 industryCondition的数据 ： dict[key]\n",
    "> 2. 请找出 关键字为 'code' 为 020 的所有数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "0ff9fb8e",
   "metadata": {},
   "outputs": [],
   "source": [
    "test_dict={\"flag\":1,\"data\":{\"educationCondition\":[{\"code\":\"010\",\"name\":\"博士\"},{\"code\":\"020\",\"name\":\"MBA/EMBA\"},{\"code\":\"030\",\"name\":\"硕士\"},{\"code\":\"040\",\"name\":\"本科\"},{\"code\":\"050\",\"name\":\"大专\"},{\"code\":\"060\",\"name\":\"中专/中技\"},{\"code\":\"080\",\"name\":\"高中\"},{\"code\":\"090\",\"name\":\"初中及以下\"}],\"stageCondition\":[{\"code\":\"01\",\"name\":\"天使轮\"},{\"code\":\"02\",\"name\":\"A轮\"},{\"code\":\"03\",\"name\":\"B轮\"},{\"code\":\"04\",\"name\":\"C轮\"},{\"code\":\"05\",\"name\":\"D轮及以上\"},{\"code\":\"06\",\"name\":\"已上市\"},{\"code\":\"07\",\"name\":\"战略融资\"},{\"code\":\"08\",\"name\":\"融资未公开\"},{\"code\":\"99\",\"name\":\"其他\"}],\"scaleCondition\":[{\"code\":\"010\",\"name\":\"1-49人\"},{\"code\":\"020\",\"name\":\"50-99人\"},{\"code\":\"030\",\"name\":\"100-499人\"},{\"code\":\"040\",\"name\":\"500-999人\"},{\"code\":\"050\",\"name\":\"1000-2000人\"},{\"code\":\"060\",\"name\":\"2000-5000人\"},{\"code\":\"070\",\"name\":\"5000-10000人\"},{\"code\":\"080\",\"name\":\"10000人以上\"}],\"compKindCondition\":[{\"code\":\"010\",\"name\":\"外商独资·外企办事处\"},{\"code\":\"020\",\"name\":\"中外合营(合资·合作)\"},{\"code\":\"030\",\"name\":\"私营·民营企业\"},{\"code\":\"040\",\"name\":\"国有企业\"},{\"code\":\"050\",\"name\":\"国内上市公司\"},{\"code\":\"060\",\"name\":\"政府机关／非盈利机构\"},{\"code\":\"070\",\"name\":\"事业单位\"},{\"code\":\"999\",\"name\":\"其他\"}],\"industryCondition\":[{\"code\":\"1\",\"children\":[{\"code\":\"040\",\"name\":\"互联网/移动互联网/电子商务\"},{\"code\":\"420\",\"name\":\"游戏产业\"},{\"code\":\"010\",\"name\":\"计算机软件\"},{\"code\":\"030\",\"name\":\"IT服务/系统集成\"}],\"name\":\"互联网.游戏.软件\"},{\"code\":\"2\",\"children\":[{\"code\":\"050\",\"name\":\"电子技术/半导体/集成电路\"},{\"code\":\"060\",\"name\":\"通信(设备/运营/增值)\"},{\"code\":\"020\",\"name\":\"计算机硬件/网络设备\"}],\"name\":\"电子.通信.硬件\"},{\"code\":\"3\",\"children\":[{\"code\":\"080\",\"name\":\"房地产开发/建筑/建材/工程\"},{\"code\":\"090\",\"name\":\"房地产服务(物业管理/地产经纪)\"},{\"code\":\"100\",\"name\":\"规划/设计/装潢\"}],\"name\":\"房地产.建筑.物业\"},{\"code\":\"4\",\"children\":[{\"code\":\"130\",\"name\":\"银行\"},{\"code\":\"140\",\"name\":\"保险\"},{\"code\":\"150\",\"name\":\"基金/证券/期货/投资\"},{\"code\":\"430\",\"name\":\"会计/审计\"},{\"code\":\"500\",\"name\":\"信托/担保/拍卖/典当\"}],\"name\":\"金融\"},{\"code\":\"5\",\"children\":[{\"code\":\"190\",\"name\":\"食品/饮料/烟酒/日化\"},{\"code\":\"240\",\"name\":\"百货/批发/零售\"},{\"code\":\"200\",\"name\":\"服装服饰/纺织/皮革\"},{\"code\":\"210\",\"name\":\"家具/家电\"},{\"code\":\"220\",\"name\":\"办公用品及设备\"},{\"code\":\"460\",\"name\":\"奢侈品/收藏品\"},{\"code\":\"470\",\"name\":\"工艺品/珠宝/玩具\"}],\"name\":\"消费品\"},{\"code\":\"6\",\"children\":[{\"code\":\"350\",\"name\":\"汽车/摩托车\"},{\"code\":\"360\",\"name\":\"机械制造/机电/重工\"},{\"code\":\"180\",\"name\":\"印刷/包装/造纸\"},{\"code\":\"340\",\"name\":\"仪器/仪表/工业自动化/电气\"},{\"code\":\"370\",\"name\":\"原材料及加工\"}],\"name\":\"汽车.机械.制造\"},{\"code\":\"7\",\"children\":[{\"code\":\"110\",\"name\":\"中介服务\"},{\"code\":\"120\",\"name\":\"专业服务(咨询/财会/法律/翻译等)\"},{\"code\":\"440\",\"name\":\"外包服务\"},{\"code\":\"450\",\"name\":\"检测/认证\"},{\"code\":\"230\",\"name\":\"旅游/酒店/餐饮服务/生活服务\"},{\"code\":\"260\",\"name\":\"娱乐/休闲/体育\"},{\"code\":\"510\",\"name\":\"租赁服务\"}],\"name\":\"服务.外包.中介\"},{\"code\":\"8\",\"children\":[{\"code\":\"070\",\"name\":\"广告/公关/市场推广/会展\"},{\"code\":\"170\",\"name\":\"影视/媒体/艺术/文化/出版\"},{\"code\":\"380\",\"name\":\"教育/培训/学术/科研/院校\"}],\"name\":\"广告.传媒.教育.文化\"},{\"code\":\"9\",\"children\":[{\"code\":\"250\",\"name\":\"交通/物流/运输\"},{\"code\":\"160\",\"name\":\"贸易/进出口\"},{\"code\":\"480\",\"name\":\"航空/航天\"}],\"name\":\"交通.贸易.物流\"},{\"code\":\"10\",\"children\":[{\"code\":\"270\",\"name\":\"制药/生物工程\"},{\"code\":\"280\",\"name\":\"医疗/保健/美容/卫生服务\"},{\"code\":\"290\",\"name\":\"医疗设备/器械\"}],\"name\":\"制药.医疗\"},{\"code\":\"11\",\"children\":[{\"code\":\"300\",\"name\":\"环保\"},{\"code\":\"310\",\"name\":\"石油/石化/化工\"},{\"code\":\"320\",\"name\":\"采掘/冶炼/矿产\"},{\"code\":\"330\",\"name\":\"能源(电力/水利)\"},{\"code\":\"490\",\"name\":\"新能源\"}],\"name\":\"能源.化工.环保\"},{\"code\":\"12\",\"children\":[{\"code\":\"390\",\"name\":\"政府/公共事业/非营利机构\"},{\"code\":\"410\",\"name\":\"农/林/牧/渔\"},{\"code\":\"400\",\"name\":\"其他\"}],\"name\":\"政府.农林牧渔\"}],\"jobKindCondition\":[{\"code\":\"1\",\"name\":\"猎头职位\"},{\"code\":\"2\",\"name\":\"企业职位\"}]}}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "79e7ac0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'flag': 1,\n",
       " 'data': {'educationCondition': [{'code': '010', 'name': '博士'},\n",
       "   {'code': '020', 'name': 'MBA/EMBA'},\n",
       "   {'code': '030', 'name': '硕士'},\n",
       "   {'code': '040', 'name': '本科'},\n",
       "   {'code': '050', 'name': '大专'},\n",
       "   {'code': '060', 'name': '中专/中技'},\n",
       "   {'code': '080', 'name': '高中'},\n",
       "   {'code': '090', 'name': '初中及以下'}],\n",
       "  'stageCondition': [{'code': '01', 'name': '天使轮'},\n",
       "   {'code': '02', 'name': 'A轮'},\n",
       "   {'code': '03', 'name': 'B轮'},\n",
       "   {'code': '04', 'name': 'C轮'},\n",
       "   {'code': '05', 'name': 'D轮及以上'},\n",
       "   {'code': '06', 'name': '已上市'},\n",
       "   {'code': '07', 'name': '战略融资'},\n",
       "   {'code': '08', 'name': '融资未公开'},\n",
       "   {'code': '99', 'name': '其他'}],\n",
       "  'scaleCondition': [{'code': '010', 'name': '1-49人'},\n",
       "   {'code': '020', 'name': '50-99人'},\n",
       "   {'code': '030', 'name': '100-499人'},\n",
       "   {'code': '040', 'name': '500-999人'},\n",
       "   {'code': '050', 'name': '1000-2000人'},\n",
       "   {'code': '060', 'name': '2000-5000人'},\n",
       "   {'code': '070', 'name': '5000-10000人'},\n",
       "   {'code': '080', 'name': '10000人以上'}],\n",
       "  'compKindCondition': [{'code': '010', 'name': '外商独资·外企办事处'},\n",
       "   {'code': '020', 'name': '中外合营(合资·合作)'},\n",
       "   {'code': '030', 'name': '私营·民营企业'},\n",
       "   {'code': '040', 'name': '国有企业'},\n",
       "   {'code': '050', 'name': '国内上市公司'},\n",
       "   {'code': '060', 'name': '政府机关／非盈利机构'},\n",
       "   {'code': '070', 'name': '事业单位'},\n",
       "   {'code': '999', 'name': '其他'}],\n",
       "  'industryCondition': [{'code': '1',\n",
       "    'children': [{'code': '040', 'name': '互联网/移动互联网/电子商务'},\n",
       "     {'code': '420', 'name': '游戏产业'},\n",
       "     {'code': '010', 'name': '计算机软件'},\n",
       "     {'code': '030', 'name': 'IT服务/系统集成'}],\n",
       "    'name': '互联网.游戏.软件'},\n",
       "   {'code': '2',\n",
       "    'children': [{'code': '050', 'name': '电子技术/半导体/集成电路'},\n",
       "     {'code': '060', 'name': '通信(设备/运营/增值)'},\n",
       "     {'code': '020', 'name': '计算机硬件/网络设备'}],\n",
       "    'name': '电子.通信.硬件'},\n",
       "   {'code': '3',\n",
       "    'children': [{'code': '080', 'name': '房地产开发/建筑/建材/工程'},\n",
       "     {'code': '090', 'name': '房地产服务(物业管理/地产经纪)'},\n",
       "     {'code': '100', 'name': '规划/设计/装潢'}],\n",
       "    'name': '房地产.建筑.物业'},\n",
       "   {'code': '4',\n",
       "    'children': [{'code': '130', 'name': '银行'},\n",
       "     {'code': '140', 'name': '保险'},\n",
       "     {'code': '150', 'name': '基金/证券/期货/投资'},\n",
       "     {'code': '430', 'name': '会计/审计'},\n",
       "     {'code': '500', 'name': '信托/担保/拍卖/典当'}],\n",
       "    'name': '金融'},\n",
       "   {'code': '5',\n",
       "    'children': [{'code': '190', 'name': '食品/饮料/烟酒/日化'},\n",
       "     {'code': '240', 'name': '百货/批发/零售'},\n",
       "     {'code': '200', 'name': '服装服饰/纺织/皮革'},\n",
       "     {'code': '210', 'name': '家具/家电'},\n",
       "     {'code': '220', 'name': '办公用品及设备'},\n",
       "     {'code': '460', 'name': '奢侈品/收藏品'},\n",
       "     {'code': '470', 'name': '工艺品/珠宝/玩具'}],\n",
       "    'name': '消费品'},\n",
       "   {'code': '6',\n",
       "    'children': [{'code': '350', 'name': '汽车/摩托车'},\n",
       "     {'code': '360', 'name': '机械制造/机电/重工'},\n",
       "     {'code': '180', 'name': '印刷/包装/造纸'},\n",
       "     {'code': '340', 'name': '仪器/仪表/工业自动化/电气'},\n",
       "     {'code': '370', 'name': '原材料及加工'}],\n",
       "    'name': '汽车.机械.制造'},\n",
       "   {'code': '7',\n",
       "    'children': [{'code': '110', 'name': '中介服务'},\n",
       "     {'code': '120', 'name': '专业服务(咨询/财会/法律/翻译等)'},\n",
       "     {'code': '440', 'name': '外包服务'},\n",
       "     {'code': '450', 'name': '检测/认证'},\n",
       "     {'code': '230', 'name': '旅游/酒店/餐饮服务/生活服务'},\n",
       "     {'code': '260', 'name': '娱乐/休闲/体育'},\n",
       "     {'code': '510', 'name': '租赁服务'}],\n",
       "    'name': '服务.外包.中介'},\n",
       "   {'code': '8',\n",
       "    'children': [{'code': '070', 'name': '广告/公关/市场推广/会展'},\n",
       "     {'code': '170', 'name': '影视/媒体/艺术/文化/出版'},\n",
       "     {'code': '380', 'name': '教育/培训/学术/科研/院校'}],\n",
       "    'name': '广告.传媒.教育.文化'},\n",
       "   {'code': '9',\n",
       "    'children': [{'code': '250', 'name': '交通/物流/运输'},\n",
       "     {'code': '160', 'name': '贸易/进出口'},\n",
       "     {'code': '480', 'name': '航空/航天'}],\n",
       "    'name': '交通.贸易.物流'},\n",
       "   {'code': '10',\n",
       "    'children': [{'code': '270', 'name': '制药/生物工程'},\n",
       "     {'code': '280', 'name': '医疗/保健/美容/卫生服务'},\n",
       "     {'code': '290', 'name': '医疗设备/器械'}],\n",
       "    'name': '制药.医疗'},\n",
       "   {'code': '11',\n",
       "    'children': [{'code': '300', 'name': '环保'},\n",
       "     {'code': '310', 'name': '石油/石化/化工'},\n",
       "     {'code': '320', 'name': '采掘/冶炼/矿产'},\n",
       "     {'code': '330', 'name': '能源(电力/水利)'},\n",
       "     {'code': '490', 'name': '新能源'}],\n",
       "    'name': '能源.化工.环保'},\n",
       "   {'code': '12',\n",
       "    'children': [{'code': '390', 'name': '政府/公共事业/非营利机构'},\n",
       "     {'code': '410', 'name': '农/林/牧/渔'},\n",
       "     {'code': '400', 'name': '其他'}],\n",
       "    'name': '政府.农林牧渔'}],\n",
       "  'jobKindCondition': [{'code': '1', 'name': '猎头职位'},\n",
       "   {'code': '2', 'name': '企业职位'}]}}"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "4ac1bfd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['educationCondition', 'stageCondition', 'scaleCondition', 'compKindCondition', 'industryCondition', 'jobKindCondition'])"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_dict['data'].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "b0914301",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'code': '1',\n",
       "  'children': [{'code': '040', 'name': '互联网/移动互联网/电子商务'},\n",
       "   {'code': '420', 'name': '游戏产业'},\n",
       "   {'code': '010', 'name': '计算机软件'},\n",
       "   {'code': '030', 'name': 'IT服务/系统集成'}],\n",
       "  'name': '互联网.游戏.软件'},\n",
       " {'code': '2',\n",
       "  'children': [{'code': '050', 'name': '电子技术/半导体/集成电路'},\n",
       "   {'code': '060', 'name': '通信(设备/运营/增值)'},\n",
       "   {'code': '020', 'name': '计算机硬件/网络设备'}],\n",
       "  'name': '电子.通信.硬件'},\n",
       " {'code': '3',\n",
       "  'children': [{'code': '080', 'name': '房地产开发/建筑/建材/工程'},\n",
       "   {'code': '090', 'name': '房地产服务(物业管理/地产经纪)'},\n",
       "   {'code': '100', 'name': '规划/设计/装潢'}],\n",
       "  'name': '房地产.建筑.物业'},\n",
       " {'code': '4',\n",
       "  'children': [{'code': '130', 'name': '银行'},\n",
       "   {'code': '140', 'name': '保险'},\n",
       "   {'code': '150', 'name': '基金/证券/期货/投资'},\n",
       "   {'code': '430', 'name': '会计/审计'},\n",
       "   {'code': '500', 'name': '信托/担保/拍卖/典当'}],\n",
       "  'name': '金融'},\n",
       " {'code': '5',\n",
       "  'children': [{'code': '190', 'name': '食品/饮料/烟酒/日化'},\n",
       "   {'code': '240', 'name': '百货/批发/零售'},\n",
       "   {'code': '200', 'name': '服装服饰/纺织/皮革'},\n",
       "   {'code': '210', 'name': '家具/家电'},\n",
       "   {'code': '220', 'name': '办公用品及设备'},\n",
       "   {'code': '460', 'name': '奢侈品/收藏品'},\n",
       "   {'code': '470', 'name': '工艺品/珠宝/玩具'}],\n",
       "  'name': '消费品'},\n",
       " {'code': '6',\n",
       "  'children': [{'code': '350', 'name': '汽车/摩托车'},\n",
       "   {'code': '360', 'name': '机械制造/机电/重工'},\n",
       "   {'code': '180', 'name': '印刷/包装/造纸'},\n",
       "   {'code': '340', 'name': '仪器/仪表/工业自动化/电气'},\n",
       "   {'code': '370', 'name': '原材料及加工'}],\n",
       "  'name': '汽车.机械.制造'},\n",
       " {'code': '7',\n",
       "  'children': [{'code': '110', 'name': '中介服务'},\n",
       "   {'code': '120', 'name': '专业服务(咨询/财会/法律/翻译等)'},\n",
       "   {'code': '440', 'name': '外包服务'},\n",
       "   {'code': '450', 'name': '检测/认证'},\n",
       "   {'code': '230', 'name': '旅游/酒店/餐饮服务/生活服务'},\n",
       "   {'code': '260', 'name': '娱乐/休闲/体育'},\n",
       "   {'code': '510', 'name': '租赁服务'}],\n",
       "  'name': '服务.外包.中介'},\n",
       " {'code': '8',\n",
       "  'children': [{'code': '070', 'name': '广告/公关/市场推广/会展'},\n",
       "   {'code': '170', 'name': '影视/媒体/艺术/文化/出版'},\n",
       "   {'code': '380', 'name': '教育/培训/学术/科研/院校'}],\n",
       "  'name': '广告.传媒.教育.文化'},\n",
       " {'code': '9',\n",
       "  'children': [{'code': '250', 'name': '交通/物流/运输'},\n",
       "   {'code': '160', 'name': '贸易/进出口'},\n",
       "   {'code': '480', 'name': '航空/航天'}],\n",
       "  'name': '交通.贸易.物流'},\n",
       " {'code': '10',\n",
       "  'children': [{'code': '270', 'name': '制药/生物工程'},\n",
       "   {'code': '280', 'name': '医疗/保健/美容/卫生服务'},\n",
       "   {'code': '290', 'name': '医疗设备/器械'}],\n",
       "  'name': '制药.医疗'},\n",
       " {'code': '11',\n",
       "  'children': [{'code': '300', 'name': '环保'},\n",
       "   {'code': '310', 'name': '石油/石化/化工'},\n",
       "   {'code': '320', 'name': '采掘/冶炼/矿产'},\n",
       "   {'code': '330', 'name': '能源(电力/水利)'},\n",
       "   {'code': '490', 'name': '新能源'}],\n",
       "  'name': '能源.化工.环保'},\n",
       " {'code': '12',\n",
       "  'children': [{'code': '390', 'name': '政府/公共事业/非营利机构'},\n",
       "   {'code': '410', 'name': '农/林/牧/渔'},\n",
       "   {'code': '400', 'name': '其他'}],\n",
       "  'name': '政府.农林牧渔'}]"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_dict['data']['industryCondition']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "107bb859",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(test_dict['data']['industryCondition'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c8cb915",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
